package com.qf.zwy.office.conteroller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qf.office.common.base.result.ResponseResult;
import com.qf.zwy.office.common.qo.PagingQueryQo;
import com.qf.zwy.office.common.vo.ApprovalFormVo;
import com.qf.zwy.office.service.ApprovalService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author 子未语
 */
@Api("审批管理")
@Validated
@RestController
@RequestMapping("/approval")
public class ApprovalController {

    @Resource
    private ApprovalService approvalService;


    @PostMapping("query/all")
    @ApiOperation("分页查询所有数据")
    @ApiImplicitParams({@ApiImplicitParam(name = "page", value = "页数"),
            @ApiImplicitParam(name = "size", value = "大小"),
            @ApiImplicitParam(name = "pagingQueryQo", value = "请求搜索的条件")})
    public ResponseResult<IPage<ApprovalFormVo>> pagingQuery(@RequestParam(defaultValue = "1")   Integer page,
                                                             @RequestParam(defaultValue = "3")   Integer size,
                                                             @RequestBody PagingQueryQo pagingQueryQo) {
        return ResponseResult.success(approvalService.pagingQuery(page, size, pagingQueryQo));
    }



    @PostMapping("/{id}")
    @ApiOperation("查询单个数据")
    @ApiImplicitParams({@ApiImplicitParam(name = "id",value = "需要查询的id")})
    public ResponseResult<ApprovalFormVo> queryOne(@PathVariable Integer id){
        return ResponseResult.success(approvalService.queryOne(id));
    }
}
